package com.buddies.lottery.widget;

import android.content.Context;

import com.kaopiz.kprogresshud.KProgressHUD;

public class ProgressDialog {

    public static KProgressHUD show(Context context) {
        return show(context, "正在加载");
    }

    public static KProgressHUD show(Context context, String message) {
        return show(context, message, false);
    }

    public static KProgressHUD show(Context context, String message, boolean cancelable) {
        return KProgressHUD.create(context)
                .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
                .setLabel(message)
                .setCancellable(cancelable)
                .setAnimationSpeed(2)
                .setDimAmount(0.5f)
                .show();
    }

    public static void hide(KProgressHUD dialog) {
        if (dialog != null) {
            try {
                dialog.dismiss();
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    }

}
